

* +++++++++++++++++++++
* CLEAN DATA ON
* LOCAL ECONOMY
* +++++++++++++++++++++

* GDP per capita
import excel "${data_raw}/economy/vgrdl_r2b1_bs2019.xlsx", clear sheet("6.")

keep if G == "3"

keep C H AH

ren (C H AH) (ags place_name gdp_pc)
destring ags, replace

tempfile gdp_pc
save `gdp_pc'

* average income
import excel "${data_raw}/economy/vgrdl_r2b2_bs2019_2.xlsx", clear sheet(5)

keep if G == "3"

keep C H AA

ren (C H AA) (ags place_name avg_inc)
destring ags, replace

tempfile avg_inc
save `avg_inc'

* average hourly wage
import excel "${data_raw}/economy/vgrdl_r2b2_bs2019_2.xlsx", clear sheet(8)

keep if G == "3"

keep C H AA

ren (C H AA) (ags place_name avg_hrly_wage)
destring ags, replace

* combine, clean up and save
merge 1:1 ags using `avg_inc', nogen assert(3)
merge 1:1 ags using `gdp_pc', nogen assert(3)

replace ags = 2000 if ags == 2
replace ags = 11000 if ags == 11

* create logs
foreach var in avg_hrly_wage avg_inc gdp_pc {
	gen log_`var' = log(`var')
}


save "${data_derived}/econ_vars.dta", replace
